package core.api.offer;

import jade.util.Logger;

import java.util.ArrayList;
import java.util.Date;

import core.datamodel.AccountData;
import core.datamodel.Constants;
import core.datamodel.Element;
import core.datamodel.ElementValue;
import core.datamodel.Resource;
import core.datamodel.ResourceCounter;

public class OfferFlat extends OfferDefinition {
	Logger log = Logger.getJADELogger(this.getClass().getName());

	
	public OfferFlat() {
		super("FLAT");
		// TODO Auto-generated constructor stub
	}

	public AccountData calculate(Resource  resource, Date  startTime ,long interval) {
		log.info("Richiesto il calcolo offerta flat per il timestamp " + startTime);
		AccountData account = null;
		
		if (resource.getResourceType().equals(Constants.RESOURCE_TYPE_VIRTUAL_MACHINE)){
			log.info("Richiesto il calcolo per VirtualMachine  offerta Flat" + startTime);
			OfferVirtualMachine offer = new OfferVirtualMachine(true);
			account = offer.calculate(resource, startTime, interval);
		
		} else if (resource.getResourceType().equals(Constants.RESOURCE_TYPE_VLAN)){
			log.info("Richiesto il calcolo per Vlan  offerta Flat" + startTime);
			OfferVlan offer = new OfferVlan(true);
			account = offer.calculate(resource, startTime, interval);
		
		} else if (resource.getResourceType().equals(Constants.RESOURCE_TYPE_DATA_REPLICATION)){
			log.info("Richiesto il calcolo per Data Replication  offerta Flat" + startTime);
			OfferDataReplication offer = new OfferDataReplication(true);
			account = offer.calculate(resource, startTime, interval);
		}

		return account;
	}
	
	
	

	@Override
	public boolean isUsageRequired() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isEventRequired() {
		// TODO Auto-generated method stub
		return false;
	}

}
